# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: Severen Redwood <me@severen.dev>
# Contributor: Tomasz Jakub Rup <tomasz.rup@gmail.com>

pkgname=pnpm
pkgver=8.11.0
pkgrel=1
pkgdesc='Fast, disk space efficient package manager'
arch=('any')
url=https://pnpm.io
license=('MIT')
depends=('node-gyp')
makedepends=('git' 'pnpm')
source=("git+https://github.com/$pkgname/$pkgname.git#tag=v$pkgver?signed")
b2sums=('SKIP')
validpgpkeys=('7B74D1299568B586BA9962B5649E4D4AF74E7DEC') # Zoltan Kochan <z@kochan.io>

build() {
  cd $pkgname/$pkgname
  pnpm install --frozen-lockfile
  pnpm run compile
}

package() {
  local mod_dir=/usr/lib/node_modules/$pkgname
  install -d "$pkgdir"/{usr/bin,$mod_dir/dist}
  ln -s $mod_dir/bin/$pkgname.cjs "$pkgdir"/usr/bin/$pkgname
  ln -s $mod_dir/bin/pnpx.cjs "$pkgdir"/usr/bin/pnpx

  cd $pkgname/$pkgname
  cp -r bin package.json "$pkgdir"/$mod_dir
  install -Dt "$pkgdir"/usr/share/licenses/$pkgname LICENSE
  cd dist
  cp -r $pkgname.cjs pnpmrc scripts worker.js "$pkgdir"/$mod_dir/dist
}
